<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>

<form id="form_evento"
	action="<?php echo url_for('evento/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id_evento='.$form->getObject()->getIdEvento() : '')) ?>"
	method="post"
	<?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>
>
	<?php if (!$form->getObject()->isNew()): ?>
	<input type="hidden" name="sf_method" value="put" />
	<input type="hidden" name="id_evento" value="<?php echo $form->getObject()->getIdEvento() ?>" />
	<?php endif; ?>
	<?php echo $form->renderHiddenFields() ?>

<div class="tabs">
    <ul>
        <li><a href="#tab_dados">Dados</a></li>
         <?php if (!$form->getObject()->isNew()): ?>
            <li><a href="<?php echo url_for('midia/arquivos?ref_name=id_evento&ref_value='.$form->getObject()->getIdEvento().'&hasmany=true'); ?>">Arquivo(s)</a></li>
        <?php else: ?>
            <li><a href="#tab_midia">Imagens(s)</a></li>
        <?php endif; ?>
    </ul>
    <div id="tab_dados">
		<?php include_partial('evento', array('form' => $form))?>
    </div>
    <?php if ($form->getObject()->isNew()): ?>
    <div id="tab_midia">
    	<?php

			include_component(
				'midia',
				'new',
				array(
					'form' => $form,
					'hasmany' => true
				)
			);
        ?>
    </div>
	<?php endif; ?>
</div>

<?php
	comandos_form(
		link_to(
			':: Voltar ::',
			'evento/list',
			array('class' => 'botao')
		),
		button_to_function(
			':: Salvar ::',
			"$('#form_evento').submit()",
			array('class' => 'botao')
		)
	);
?>

</form>

<script>
$(document).ready(function(){
	App.bodydata.toTab();
});
</script>